<template>
  <div class="app-container">
    <Find :formList="formList" @Launchform="Launchform3" @findClicked="findData1" />

    <el-card style="margin-top: 10px" shadow="always" :body-style="{ padding: '5px' }">
      <div>
        <div style="width: 100%">
          <Tables
            @modifTable9="modifTable9"
            @modifTable8="modifTable8"
            @modifTable7="modifTable7"
            @currentRow="currentRow"
            :functionList5="true"
            :isLoading="isLoading"
            :tableHeader="tableHeader"
            :tableData="mainQueryTableDate"
            :TableHeight="47"
          />
          <PageModule :PageData="{ total, buttonS: true }" @pageSizeChange="handleSizeChange" @pageChange="handleCurrentChange" />
        </div>
      </div>

      <div>
        <h1 style="font-size: 18px">{{ $t(`Print.LabelDetails`) }}</h1>
        <Find style="margin-bottom: 20px" :searchImg="false" :formList="formList1" @Launchform="Launchform" @findClicked="findData" />
        <Table :isLoading="isLoading1" :tableHeader="tableHeader1" :tableData="detailEnquiryTableDate" :TableHeight="45" />
        <PageModule :PageData="{ total: total1, buttonS: true }" @pageSizeChange="handleSizeChange1" @pageChange="handleCurrentChange1" />
      </div>
    </el-card>

    <el-dialog :title="printCodeParms" v-model="dialogVisible8" width="40%" class="dialog pb0">
      <div style="display: flex">
        <div style="width: 20%">
          <Table
            @selectList="selectList"
            selection
            :isLoading="isLoading1"
            :tableHeader="tableHeader3"
            :tableData="printQueryTableDate"
            :TableHeight="45"
          />
        </div>

        <div style="margin-top: 5px; margin-left: 30px">
          <div><span>{{ $t(`Print.FromThePrintRound`) }}:</span> <el-input-number v-model="detailEnquiry1Parms.lsFrom" /></div>
          <div style="margin-top: 20px"><span>{{ $t(`Print.ThePrintRoundEnds`) }}:</span> <el-input-number v-model="detailEnquiry1Parms.lsEnd" /></div>
          <div style="display: flex; margin-top: 20px">
            <span>{{ $t(`Print.PrintTheNumber`) }}:</span
            ><el-form-item>
              <el-select
                v-model="detailEnquiry1Parms.sizeNos"
                multiple
                collapse-tags
                collapse-tags-tooltip
                style="width: 152px; margin-left: 18px"
                class="JSelect"
              >
                <el-option v-for="item1 in options" :key="item1.optionValue" :label="item1.optionLabel" :value="item1.optionValue" />
              </el-select>
            </el-form-item>
          </div>
        </div>
      </div>

      <el-button style="margin-top: 20px" type="primary" size="default" @click="detailEnquiry1Methods">{{ $t(`Print.Print`) }}</el-button>
      <el-button style="margin-top: 20px" type="primary" size="default" @click="detailEnquiry1Methods">{{ $t(`Print.PrintThermalPaper`) }}</el-button>
    </el-dialog>

    <el-dialog v-model="dialogVisible9" width="40%" class="dialog pb0">
      <div>
        <span>{{ $t(`Print.FromThePrintRound`) }}:</span> <el-input-number v-model="bagQty" /><el-button style="margin-left: 20px" type="primary" size="default" @click="exit"
          >{{ $t(`Print.SetUp`) }}</el-button
        >
      </div>
      <Table selection :isLoading="isLoading1" :tableHeader="tableHeader5" :tableData="partNameParmsTableDate" :TableHeight="45" />
      <el-button style="margin-top: 20px" type="primary" size="default" @click="confirmMethods">{{ $t(`Print.Sure`) }}</el-button>
    </el-dialog>

    <div class="qrCodeContainer" style="width: 750px; height: 150px; display: none; border: 1px solid red">
      <div v-for="imageUrl in imageList" style="width: 100%" class="main qrCode">
        <div class="left">
          <span>{{ dateList }}</span>
          <img style="width: 70px; height: 70px" :src="imageUrl.labelNo" alt="" />
          <span class="size-12">{{ imageUrl.companyId }}{{ imageUrl.dispatchWorker !== null ? ' /' + imageUrl.dispatchWorker : '' }}</span>
        </div>
        <div>
          <table>
            <tr>
              <td class="size-8 center pad3" colspan="2">{{ $t(`Print.The`) }}{{ imageUrl.lsNo }}{{ $t(`Print.Round`) }}:{{ imageUrl.batchCode }}</td>
              <td class="size-8 center pad3" colspan="2">{{ lotNoAndStyle.lotNo }}</td>
            </tr>
            <tr>
              <td class="size-8 center pad3" colspan="4">{{ lotNoAndStyle.style }}</td>
            </tr>
            <tr>
              <td class="size-8 center pad3" colspan="4">{{ imageUrl.partName.value }}</td>
            </tr>
            <tr>
              <td class="size-8 center pad3">{{ $t(`Print.GuestNumber`) }}</td>
              <td class="size-8 center pad3">{{ $t(`Print.ChongdaoNo`) }}</td>
              <td class="size-8 center pad3" colspan="2">{{ imageUrl.qty }}双</td>
            </tr>
            <tr>
              <td class="size-8 center pad3">{{ imageUrl.sizeNo }}#</td>
              <td class="size-8 center pad3">{{ imageUrl.cutSize }}#</td>
              <td class="size-8 center pad3">{{ $t(`Print.Deduction`) }}</td>
              <td class="size-8 center pad3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            </tr>
          </table>
          <span class="size-10" v-for="(item, index) in imageUrl.process.split('/')" style="margin-left: 2px">
            <input type="checkbox" />{{ item }}
          </span>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'ComponentLabel'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import { ref, onMounted, watch } from 'vue'

import {
  ComponentQuery,
  styleQuery,
  mainQuery,
  detailEnquiry,
  sizeQuery,
  GenerateARotationLabel,
  deleteLotNo,
  printQuery,
  sizeQuery1,
  partName,
  confirm,
  detailEnquiry1,
  printCode
} from '@/api/AccountingDepartment/ProductionLabel/ComponentLabel'
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
import QRCode from 'qrcode'

// 打印标签
const lotNol = ref('')

const printCodeParms = ref('')

const printCodeMethods = async () => {
  try {
    const result = await printCode(lotNol.value)
    printCodeParms.value = `打印标签-指令${'[' + lotNol.value + ']'}- 共有${'[' + result + ']'}轮 `
  } catch (error) {
    JMessage.error('程序异常')
  }
}

// 日期
const formatCurrentDate = (date?: any) => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  let newMonth = month > 10 ? month : '0' + month
  let newDay = day > 10 ? day : '0' + day
  return `${newMonth}/${newDay}`
}

const currentDate = ref(new Date())

// 打印
const printQRCode = () => {
  const qrCodeContainer = document.querySelector('.qrCodeContainer')
  if (qrCodeContainer && qrCodeContainer.children.length > 0) {
    const printWindow = window.open('', '部件标签打印')

    printWindow!.document.write(`
      <!DOCTYPE html>
      <html>
        <head>
          <title>打印所选标签页</title>
          <link rel="stylesheet" type="text/css" href="print.css" media="print">
          <style>
            body, html {
              margin: 0;
              padding: 0;
            }
            @page {
               margin-top: 6mm;  
                    margin-left: 0mm;  
                    margin-right: 0mm;  
                    margin-bottom: 0mm;  
            }
            @media print {
                /* 打印时的样式 */
                        .main{
                         page-break-after: always; /* 每个二维码后分页 */  
                         }


                /* 其他打印样式 */
            }
                body {  
                        margin: 0;  
                        padding: 0;
                        // transform: scale(1.5); /* 去掉缩放，可能会更好 */  
                        transform-origin: top; /* 设置缩放原点 */  
                       
                    } 
                         .qrCode {  
                              page-break-after: always; /* 每个二维码后分页 */  
                          }  
                          .qrCode:last-child {  
                              page-break-after: avoid !important; /* 最后一个二维码避免分页 */  
                          }   
            } 
                  

              } 
            h2 {
                    margin-left: initial; /* 或者设置适合打印的左边距 */
                    page-break-inside: avoid; /* 避免在h2元素内部分页 */
            }
            .pad3 {
                padding: 3px;
            }

            .main {
                display: flex;
                justify-content: center;
            }

            .left {
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                margin-right: 5px;
            }


            .title {
                display: flex;
                justify-content: center;
                margin-bottom: 10px;
            }

            .center {
                text-align: center;
            }

            .right {
                text-align: right;
            }

            .left {
                text-align: left;
            }

            .no-padding {
                padding: 0;
            }

            .no-margin {
                margin: 0;
            }

            .margin-5 {
                margin: 5px;
            }

            .margin-top-5 {
                margin-top: 5px;
            }

            .margin-top-15 {
                margin-top: 15px;
            }

            .size-8 {
                font-size: 8px !important;
            }

            .size-10 {
                font-size: 10px;
            }

            .size-12 {
                font-size: 12px;
            }

            .size-14 {
                font-size: 14px;
            }

            .size-16 {
                font-size: 17px;
            }

            .size-18 {
                font-size: 18px;
            }

            .size-24 {
                font-size: 24px;
            }

            #date-tip {
                position: relative;
            }

            span.tip {
                display: inline-block;
                height: 14px;
                line-height: 14px;
                margin-right: 30px;
            }

            table {
                font-size: 10px;
                border-collapse: collapse;
                border-spacing: 0;
                border-collapse: collapse;
                border-spacing: 0;
                empty-cells: show;
                width: 100%;
            }

            table th,
            table td {
                border: 1px solid #000;
                font-size: 12px;
            }

            table.no-border,
            table.no-border th,
            table.no-border td {
                border: 0px;
            }

            table td.no-left-border {
                border-left: 0px;
            }

            table td.no-right-border {
                border-right: 0px;
            }

            .mainTable {
                margin: 0 20px;
            }

            /* 备料派工单汇总表 */
            .header {
                display: flex;
                justify-content: space-evenly;
            }

            .footer {
                margin-top: 20px;
                margin-right: 100px;
                display: flex;
                justify-content: right;
            }



            /* 可以在这里添加更多自定义的打印样式 */
          </style>
        </head>
        <body>
      `)

    const qrCodeImages = qrCodeContainer.querySelectorAll('.qrCode')
    qrCodeImages.forEach((img) => {
      const cloneImg = img.cloneNode(true)
      printWindow!.document.body.appendChild(cloneImg)
    })

    printWindow!.document.write(`
        </body>
      </html>
    `)
    printWindow!.document.close()

    printWindow!.print()
  }
}

const detailEnquiry1Parms = ref<any>({
  lotNo: '',
  lsFrom: 1,
  lsEnd: null,
  partNames: [],
  sizeNos: []
})

const disable = ref(true)

// 需要打印的数据
const detailEnquiry1MethodsPrint = ref([])

const lotNoAndStyle = ref({
  lotNo: '',
  style: ''
})

const selectList = (row: any) => {
  detailEnquiry1Parms.value.partNames = row.map((item: any) => {
    return item.partName
  })
}

const openFullScreen2 = () => {
  const loading = ElLoading.service({
    lock: true,
    text: '正在汇总请稍后',
    background: 'rgba(0, 0, 0, 0.7)'
  })
  return loading
}

const dateList = ref()

const detailEnquiry1Methods = async () => {
  if (detailEnquiry1Parms.value.partNames.length === 0) {
    JMessage.warning('请先勾选部位')
  } else {
    let active = openFullScreen2()
    dateList.value = formatCurrentDate(currentDate.value)
    const result = await detailEnquiry1(detailEnquiry1Parms.value)
    detailEnquiry1MethodsPrint.value = result.data
    if (result.code === 200) {
      active.close()

      setTimeout(() => {
        printQRCode()
      }, 10)
    } else {
      JMessage.error(result.message)
      active.close()
    }
  }
}

const imageList = ref<any[]>([])

watch(
  () => detailEnquiry1MethodsPrint.value,
  (newValue, oldValue) => {
    makeQRCode()
  },
  { deep: true }
)

const makeQRCode = async () => {
  try {
    const imagePromises = detailEnquiry1MethodsPrint.value.map(async (item: any) => {
      let { labelNo, partName, qty, sizeNo, batchCode, lsNo, process, companyId, dispatchWorker, cutSize } = item
      labelNo = await QRCode.toDataURL(labelNo)
      return { labelNo, partName, qty, sizeNo, batchCode, lsNo, process, companyId, dispatchWorker, cutSize }
    })

    const imageUrls = await Promise.all(imagePromises)
    imageList.value = imageUrls
    console.log(imageList.value)
  } catch (error) {
    return []
  }
}

//
const partNameParms = ref('')

const partNameParmsTableDate = ref<any>([])

const bagQty = ref(200)

const exit = (row: any) => {
  partNameParmsTableDate.value = partNameParmsTableDate.value.map((item: any) => {
    item.bagQty = bagQty.value
    return item
  })
}

const confirmMethods = async () => {
  let a = false
  partNameParmsTableDate.value.map((item: any) => {
    if (item.bagQty === null) {
      a = true
    }
    return item
  })
  if (a) {
    JMessage.warning('请输入有效的袋装数量')
  } else {
    try {
      const result = await confirm(partNameParms.value, partNameParmsTableDate.value)
      if (result.code === 200) {
        mainQueryMethods()
        dialogVisible9.value = false
        JMessage.success(result.message)
      } else {
        JMessage.error(result.message)
      }
    } catch (error) {
      JMessage.error('生成出错请重试')
    }
  }
}

const partNameMethods = async () => {
  try {
    const result = await partName(partNameParms.value)
    partNameParmsTableDate.value = result.map((item: any) => {
      item.change = 'Y'
      item.confirmChange = true
      item.bagQty = null
      // item.partName = item.partName.value
      item.partName1 = item.partName.value
      item.partName = item.partName.key
      return item
    })
  } catch (error) {
    JMessage.error('表格查询出错')
  }
}

const dialogVisible9 = ref(false)

// 打印
const lotNoA = ref('')
const printQueryTableDate = ref([])

const options = ref<any>([])

const lsit = ref<any>('')

const printQueryMethods = async () => {
  try {
    const result = await printQuery(lotNoA.value)
    printQueryTableDate.value = result.map((item:any) => {
      item.partName1 = item.partName.value
      item.partName = item.partName.key
      return item
    })
  } catch (error) {
    JMessage.warning('部位查询出错')
  }
}

const modifTable9 = (row: any) => {
  lotNoA.value = row.row.lotNo
  lsit.value = ''
  printQueryMethods()
  sizeQueryMethods1()
  dialogVisible8.value = true

  disable.value = true
  lotNoAndStyle.value.lotNo = row.row.lotNo
  lotNoAndStyle.value.style = row.row.style
  lotNol.value = row.row.lotNo

  detailEnquiry1Parms.value.lotNo = row.row.lotNo

  detailEnquiry1Parms.value.sizeNos = []
  printCodeMethods()
}

const dialogVisible8 = ref(false)

// 删除标签
const lotNoList = ref('')

const modifTable8 = (row: any) => {
  lotNoList.value = row.row.lotNo
  handleCloseMateriaLKlc()
}

const deleteLotNoMethods = async () => {
  try {
    const result = await deleteLotNo(lotNoList.value)
    if (result.code === 200) {
      mainQueryMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('删除轮次标签出错')
  }
}

const handleCloseMateriaLKlc = (_done?: () => void) => {
  ElMessageBox.confirm('确认要删除数据吗?')
    .then(async () => {
      deleteLotNoMethods()
    })
    .catch(() => {})
}

// 生成轮次标签
const GenerateARotationLabelParms = ref<any>({
  lotNo: '',
  override: ''
})

const modifTable7 = (row: any) => {
  GenerateARotationLabelParms.value.lotNo = row.lotNo
  partNameParms.value = row.lotNo
  if (row.labelFlag === 'Y' && row.processFlag === 'Y') {
    GenerateARotationLabelParms.value.override = false
    GenerateARotationLabelMethods()
  } else {
    GenerateARotationLabelParms.value.override = true
    GenerateARotationLabelMethods1()
  }
}

const GenerateARotationLabelMethods1 = async () => {
  try {
    const result = await GenerateARotationLabel(GenerateARotationLabelParms.value.lotNo, GenerateARotationLabelParms.value.override)
    if (result.code === 200) {
      dialogVisible9.value = true
      partNameMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('生成轮次标签出错请重试')
  }
}

const GenerateARotationLabelMethods = async () => {
  try {
    const result = await GenerateARotationLabel(GenerateARotationLabelParms.value.lotNo, GenerateARotationLabelParms.value.override)
    if (result.code === 200) {
      mainQueryMethods()
      JMessage.success(result.message)
    } else if (result.code === 301) {
      handleCloseMateriaLKlc5()
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('生成轮次标签出错请重试')
  }
}

const handleCloseMateriaLKlc5 = () => {
  ElMessageBox.confirm('是否覆盖旧资料?')
    .then(async () => {
      GenerateARotationLabelParms.value.override = true
      GenerateARotationLabelMethods()
    })
    .catch(() => {})
}

// 号码查询
const lotNo = ref('')

const sizeQueryMethods = async () => {
  try {
    const result = await sizeQuery(lotNo.value)

    const NewArrayList = result.reduce((arr: any, item: any) => {
      if (item.sizeNo) {
        // 只添加非空的 typeName 和 typeNo
        arr.push(item.sizeNo)
      }
      return arr
    }, [])

    formList1.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
  } catch (error) {
    JMessage.error('号码查询出错')
  }
}

const sizeQueryMethods1 = async () => {
  try {
    const result = await sizeQuery1(lotNoA.value)

    const NewArrayList1 = result.reduce((arr: any, item: any) => {
      if (item.sizeNo && item.qty) {
        // 只添加非空的 typeName 和 typeNo
        arr.push(item.sizeNo)
      }
      return arr
    }, [])

    options.value = EvaluatesTheArrayReturnValue(NewArrayList1)
  } catch (error) {
    JMessage.error('号码查询出错')
  }
}

// 明细查询
const detailEnquiryParms = ref<any>({
  companyId: '',
  cutSeq: '',
  lotNo: '',
  lsNo: '',
  partName: '',
  sizeNo: '',
  pageNum: 1,
  pageSize: 40
})

const Launchform = (row: any) => {
  detailEnquiryParms.value.sizeNo = row[0].selectValue
  detailEnquiryParms.value.partName = row[1].inputValue
  detailEnquiryParms.value.cutSeq = row[2].selectValue
  if (detailEnquiryParms.value.cutSeq === '一裁') {
    detailEnquiryParms.value.cutSeq = 1
  }
  if (detailEnquiryParms.value.cutSeq === '二裁') {
    detailEnquiryParms.value.cutSeq = 2
  }
  if (detailEnquiryParms.value.cutSeq === '三裁') {
    detailEnquiryParms.value.cutSeq = 3
  }
  if (detailEnquiryParms.value.cutSeq === '四裁') {
    detailEnquiryParms.value.cutSeq = 4
  }
  if (detailEnquiryParms.value.cutSeq === '所有') {
    detailEnquiryParms.value.cutSeq = ''
  }
  detailEnquiryMethods()
}

const total1 = ref(0)

const handleSizeChange1 = (val: number) => {
  detailEnquiryParms.value.pageSize = val
  detailEnquiryMethods()
}

const handleCurrentChange1 = (val: number) => {
  detailEnquiryParms.value.pageNum = val
  detailEnquiryMethods()
}

const currentRow = (row: any) => {
  detailEnquiryParms.value.companyId = row.companyId
  detailEnquiryParms.value.lotNo = row.lotNo
  detailEnquiryParms.value.lsNo = row.lsNo
  lotNo.value = row.lotNo
  sizeQueryMethods()
  detailEnquiryMethods()
}

const detailEnquiryTableDate = ref([])

const isLoading1 = ref(true)

const detailEnquiryMethods = async () => {
  isLoading1.value = true
  try {
    const result = await detailEnquiry(detailEnquiryParms.value)
    detailEnquiryTableDate.value = result.list.map((item:any) => {
      item.partName1 = item.partName.value
      item.partName = item.partName.key
      return item
    })
    total1.value = result.total
    isLoading1.value = false
  } catch (error) {
    isLoading1.value = false
    JMessage.error('明细查询出错')
  }
}

// 主体查询
const mainQueryParms = ref({
  companyId: '',
  custom: '',
  flag: '',
  lotNo: '',
  pageNum: 1,
  pageSize: 40,
  style: ''
})

const Launchform3 = (row: any) => {
  mainQueryParms.value.custom = row[0].selectValue
  mainQueryParms.value.style = row[1].selectValue
  mainQueryParms.value.lotNo = row[2].inputValue
  mainQueryParms.value.flag = row[3].selectValue
  if (mainQueryParms.value.flag === '已生成') {
    mainQueryParms.value.flag = 'Y'
  } else if (mainQueryParms.value.flag === '未生成') {
    mainQueryParms.value.flag = 'N'
  } else {
    mainQueryParms.value.flag === ''
  }
  mainQueryMethods()
}

const isLoading = ref(true)

const mainQueryTableDate = ref([])

const mainQueryMethods = async () => {
  isLoading.value = true
  try {
    const result = await mainQuery(mainQueryParms.value)
    mainQueryTableDate.value = result.list
    total.value = result.total
    if (result.list.length !== 0) {
      detailEnquiryParms.value.companyId = result.list[0].companyId
      detailEnquiryParms.value.lotNo = result.list[0].lotNo
      detailEnquiryParms.value.lsNo = result.list[0].lsNo
      lotNo.value = result.list[0].lotNo
      sizeQueryMethods()
      detailEnquiryMethods()
    }
    isLoading.value = false
  } catch (error) {
    isLoading.value = false
  }
}

const total = ref(0)

const handleSizeChange = (val: number) => {
  mainQueryParms.value.pageSize = val
  mainQueryMethods()
}

const handleCurrentChange = (val: number) => {
  mainQueryParms.value.pageNum = val
  mainQueryMethods()
}

// 工厂型体查询
const styleQueryMethods = async () => {
  try {
    const result1 = await styleQuery()

    formList.value[1].selectOptions = EvaluatesTheArrayReturnValue1(
      result1.map((item: any) => {
        return item.style
      })
    )
  } catch (error) {
    JMessage.error('工厂型体查询出错')
  }
}
const EvaluatesTheArrayReturnValue1 = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      value: item,
      label: item
    }
  })
}
// 部门查询
const ComponentLabelMethods = async () => {
  try {
    const result = await ComponentQuery()

    const NewArraySelectList = result.reduce((arr: any, item: any) => {
      arr.push(item.custom)

      return arr
    }, [])
    formList.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArraySelectList)
  } catch (error) {
    JMessage.error('部门查询出错')
  }
}

onMounted(() => {
  ComponentLabelMethods()

  styleQueryMethods()

  mainQueryMethods()
})

const EvaluatesTheArrayReturnValue = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      optionKey: index,
      optionValue: item,
      optionLabel: item
    }
  })
}

const formList = ref([
  {
    type: 'select',
    selectValue: '',
    selectLabel: '客户:',
    selectOptions: []
  },
  {
    type: 'selectJ',
    selectValue: '',
    selectOptions: [],
    selectP: '工厂型体:'
  },
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: '',
    selectLabel: '标签状态:'
  },
  {
    type: 'select',
    selectValue: '',
    selectOptions: [
      {
        optionKey: '1',
        optionValue: '全部',
        optionLabel: '全部'
      },

      {
        optionKey: '2',
        optionValue: '已生成',
        optionLabel: '已生成'
      },
      {
        optionKey: '3',
        optionValue: '未生成',
        optionLabel: '未生成'
      }
    ]
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList1 = ref([
  {
    type: 'select',
    selectValue: '',
    selectLabel: '号码:',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '部位',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectOptions: [
      {
        optionKey: '1',
        optionValue: '一裁',
        optionLabel: '一裁'
      },
      {
        optionKey: '2',
        optionValue: '二裁',
        optionLabel: '二裁'
      },
      {
        optionKey: '3',
        optionValue: '三裁',
        optionLabel: '三裁'
      },
      {
        optionKey: '4',
        optionValue: '四裁',
        optionLabel: '四裁'
      },
      {
        optionKey: '5',
        optionValue: '所有',
        optionLabel: '所有'
      }
    ]
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList2 = ref([
  {
    type: 'select1',
    selectValue: '',
    selectLabel: '打印号码:',
    selectOptions: []
  }
])

const findData1 = (row: string) => {
  if (row === '置空') {
    formList.value.forEach((item: any) => {
      item.selectValue = ''
      item.inputValue = ''
    })
  }
}

const findData = (row: string) => {
  if (row === '置空') {
    formList1.value.forEach((item: any) => {
      item.selectValue = ''
      item.inputValue = ''
    })
  }
}

const tableHeader = ref([
  {
    label: '品牌',
    prop: 'custom'
  },
  {
    label: '工厂型体',
    prop: 'style'
  },
  {
    label: '指令号',
    prop: 'lotNo'
  },
  {
    label: '轮数',
    prop: 'lsNo'
  },
  {
    label: '双数',
    prop: 'qty'
  },
  {
    label: '是否生成标签',
    prop: 'labelFlag'
  }
])

const tableHeader1 = ref([
  {
    label: '#',
    prop: 'id'
  },
  {
    label: '条码号码',
    prop: 'labelNo'
  },
  {
    label: '号码',
    prop: 'sizeNo'
  },
  {
    label: '部位',
    prop: 'partName1'
  },
  {
    label: '裁次',
    prop: 'cutSeq'
  },
  {
    label: '工艺',
    prop: 'process'
  },
  {
    label: '轮次',
    prop: 'lsNo'
  },
  {
    label: '装袋批次',
    prop: 'batchCode'
  },
  {
    label: '双数',
    prop: 'qty'
  },
  {
    label: '派工单号',
    prop: 'dispatchNo'
  },
  {
    label: '派工人员',
    prop: 'dispatchWorker'
  }
])

const tableHeader3 = ref([
  {
    label: '部位',
    prop: 'partName1'
  }
])

const tableHeader5 = ref([
  {
    label: '序号',
    prop: 'seqNo',
    change: true
  },
  {
    label: '部位',
    prop: 'partName1',
    change: true
  },
  {
    label: '批次最大数量',
    prop: 'qty',
    change: true
  },
  {
    label: '每袋包装数',
    prop: 'bagQty'
  }
])
</script>

<style lang="less" scoped>
.span1 {
  overflow-wrap: break-word;
  overflow: hidden;
}
</style>
